package com.itheima.health.commont;


import com.itheima.health.common.CustomException;
import com.itheima.health.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理
 */
@ControllerAdvice
@ResponseBody
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(CustomException.class)
    public Result exceptionHandler(CustomException ex) {

        return new Result(false, ex.getMessage());
    }
}
